package com.berje.vkalarm.vksdk.model;

import java.util.ArrayList;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class GroupAudioFeed {
	private ArrayList<GroupAudioNewsItem> items = new ArrayList<GroupAudioNewsItem>();

	public static GroupAudioFeed parse(JSONObject root, boolean is_comments)
			throws JSONException {
		JSONObject response = root.getJSONObject("response");
		JSONArray jitems = response.optJSONArray("items");

		GroupAudioFeed ret = new GroupAudioFeed();
		if (jitems != null) {
			ret.items = new ArrayList<GroupAudioNewsItem>();
			for (int i = 0; i < jitems.length(); i++) {
				JSONObject jitem = (JSONObject) jitems.get(i);
				GroupAudioNewsItem gmnewsitem = GroupAudioNewsItem.parse(jitem);
				if (gmnewsitem != null)
					ret.addItem(gmnewsitem);

			}
		}
		return ret;
	}

	public ArrayList<GroupAudioNewsItem> getItems() {
		return items;
	}

	public void setItems(ArrayList<GroupAudioNewsItem> items) {
		this.items = items;
	}

	public void addItem(GroupAudioNewsItem item) {
		this.items.add(item);
	}

	public String toString() {
		return String.format("GroupMusicFeed{items: %s}", items);
	}
}